package com.example.demo.service.impl;


import java.io.Serializable;
import java.util.List;

import org.apache.shiro.session.Session;

import com.example.demo.dao.SessionDao;
import com.example.demo.service.SessionService;

/**
 * Service的实现类
 * <p>@author Henry.Y</p>
 * <p>@date 2019-08-30</p>
 */
public class SessionServiceImpl implements SessionService{
	
	SessionDao sessionDao= new SessionDao();

	public Serializable doCreate(Session session){
		String sqlId= "com.example.demo.mapper.SessionMapper.insertSession";
		sessionDao.createSession(sqlId, session);
		return session.getId();
	}
	
	public int deleteSession(Session session){
		String sqlId= "com.example.demo.mapper.SessionMapper.deleteSession";
		return sessionDao.deleteSession(sqlId, String.valueOf(session.getId()));
	}
	
	
	public int updateSession(Session session){
		String sqlId= "com.example.demo.mapper.SessionMapper.updateSession";
		return sessionDao.updateSession(sqlId, session);
	}
	
	public String doReadSession(Serializable sessionId){
		String sqlId= "com.example.demo.mapper.SessionMapper.selectOneSession";
		return sessionDao.selectSession(sqlId, String.valueOf(sessionId)).getSession();
	}
	
	public List<String> selectSessionByLimit(com.example.demo.entity.Session session){
		String sqlId= "com.example.demo.mapper.SessionMapper.selectSessionByLimit";
		
		return sessionDao.selectSessionByLimit(sqlId,session);
	}
}
